package d2_collection_traverse;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Map;
import java.util.function.Consumer;

/**
 * 2024/6/4 Collection集合的遍历方式：使用Lambda表达式  Cjj  12:10
 */
public class CollectionDemo3 {
    public static void main(String[] args) {
        Collection<String> c = new ArrayList<>();
        c.add("葡萄");
        c.add("橘子");
        c.add("香蕉");
        System.out.println(c);

        c.forEach(new Consumer<String>() {
            @Override
            public void accept(String s) {
                System.out.println(s);
            }
        });

        c.forEach(System.out::println);

    }
}
